package com.dp1.pucp.Logistica.Vista;

import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author ubuntu64
 */
public class ProcesarPedidoGUI2 extends javax.swing.JInternalFrame {

    public JFrame padre;

    public JFrame getPadre() {
        return padre;
    }

    /**
     * Creates new form ProcesarPedidoGUI2
     */
    public ProcesarPedidoGUI2() {
        initComponents();
        this.setTitle("Procesar Pedido");
        try {
            setFrameIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/hombre_icono.png")));
        } catch (Exception ex) {
        }
    }

    public void addCalcularListener(ActionListener ml) {
        this.btnCalcular.addActionListener(ml);
    }

    public void addSiguienteListener(ActionListener ml) {
        this.btnSiguiente.addActionListener(ml);
    }

    public void setCantidadProductos(int cant1, int cant2, int cant3) {
//        this.txtProducto1.setText(""+cant1);
//        this.txtProducto2.setText(""+cant2);
//        this.txtProducto3.setText(""+cant3);

        ((DefaultTableModel) tblCantidades.getModel()).setRowCount(3);
        tblCantidades.setValueAt(cant1, 0, 1);
        tblCantidades.setValueAt(cant2, 1, 1);
        tblCantidades.setValueAt(cant3, 2, 1);

        ((DefaultTableModel) tblCantidades.getModel()).setRowCount(3);
        tblCantidades.setValueAt("unidades", 0, 2);
        tblCantidades.setValueAt("unidades", 1, 2);
        tblCantidades.setValueAt("unidades", 2, 2);
    }

    public void setNombreProductos(String nombre1, String nombre2, String nombre3) {
//        this.lblProducto1.setText(nombre1);
//        this.lblProducto2.setText(nombre2);
//        this.lblProducto3.setText(nombre3);

        ((DefaultTableModel) tblCantidades.getModel()).setRowCount(3);
        tblCantidades.setValueAt(nombre1, 0, 0);
        tblCantidades.setValueAt(nombre2, 1, 0);
        tblCantidades.setValueAt(nombre3, 2, 0);
    }

    public void inhabilitarCalcular() {
        this.btnCalcular.setEnabled(false);
    }

    public void inhabilitarSiguiente() {
        this.btnSiguiente.setEnabled(false);
    }

    public int getCantidad1() {
        String cant1 = this.tblCantidades.getValueAt(0, 1).toString();
        int a = Integer.parseInt(cant1);
        return a;
    }

    public int getCantidad2() {
        String cant1 = this.tblCantidades.getValueAt(1, 1).toString();

        int a = Integer.parseInt(cant1);
        return a;
    }

    public int getCantidad3() {
        String cant1 = this.tblCantidades.getValueAt(2, 1).toString();

        int a = Integer.parseInt(cant1);
        return a;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnSiguiente = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblCantidades = new javax.swing.JTable();
        btnCalcular = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();

        setClosable(true);

        btnSiguiente.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnSiguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/next.png"))); // NOI18N
        btnSiguiente.setText("Seguir");
        btnSiguiente.setBorderPainted(false);
        btnSiguiente.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSiguiente.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        tblCantidades.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "PRODUCTO", "CANTIDAD", "UNIDADES"
            }
        ));
        tblCantidades.setAutoscrolls(false);
        jScrollPane1.setViewportView(tblCantidades);

        btnCalcular.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnCalcular.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/calculadora.png"))); // NOI18N
        btnCalcular.setText("Calcular");
        btnCalcular.setBorderPainted(false);
        btnCalcular.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCalcular.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        jLabel3.setFont(new java.awt.Font("Ubuntu", 2, 10)); // NOI18N
        jLabel3.setText("Haga click en Calcular para hallar la cantidad de galletas según simulación");

        jLabel2.setText("Se procesarán los pedidos que han sido incluidos en la última simulación");

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel1.setText("Procesar Pedidos de Productos");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 435, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(35, 35, 35)
                        .addComponent(btnCalcular)
                        .addGap(0, 84, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jSeparator2)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(btnSiguiente)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel2))))
                        .addGap(20, 20, 20))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSeparator3)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(13, 13, 13)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(60, 60, 60)
                        .addComponent(btnCalcular)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 61, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnSiguiente)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCalcular;
    private javax.swing.JButton btnSiguiente;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JTable tblCantidades;
    // End of variables declaration//GEN-END:variables
}
